import 'package:dio/dio.dart';
import 'package:nyh_motorcade_app/utils/logger_utils.dart';

class LoggerInterceptors extends InterceptorsWrapper {
  @override
  void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
    LoggerUtils.logSimple("------------------------------------------------Start Http Request-------------------------------------------------");
    LoggerUtils.logSimple("RequestPath:${options.baseUrl}${options.path}");
    LoggerUtils.logSimple("RequestHeader:${options.headers}");
    LoggerUtils.logSimple("RequestData:${options.data}");
    LoggerUtils.logSimple("------------------------------------------------End Http Request---------------------------------------------------");
    super.onRequest(options, handler);
  }

  @override
  void onResponse(Response response, ResponseInterceptorHandler handler) {
    LoggerUtils.logSimple("\n");
    LoggerUtils.logSimple("------------------------------------------------Start Http Response------------------------------------------------");
    LoggerUtils.logSimple("ResponsePath:${response.realUri.toString()}");
    LoggerUtils.logSimple("ResponseData:${response.toString()}");
    LoggerUtils.log(response.data);
    LoggerUtils.logSimple("------------------------------------------------End Http Response--------------------------------------------------");
    super.onResponse(response, handler);
  }
}
